import type { MUser } from '@/model/manager'
import type { ReqPage, ResPage } from '@/model/request'
import { requests } from '@/utils/requests'

/* API Json Must Field:
  {
  "realname": "住户姓名",
  "phone": "12345678901",
  "gender": 1,
  "building": "0栋",
  "room": "000",
  "residentNature": "其他"
  }
 */
export const apiRegister = (data: MUser) => requests.post<MUser>('/user/register', data)

export const apiMUserUpdate = (user: MUser) => requests.put<MUser>('/user/update', user)

export const apiMUserList = (page: ReqPage) => requests.post<ResPage<MUser>>(`/user/mlist`, page)

export const apiOwnerFromRoom = (building: string, room: string) =>
  requests.get<MUser>(`/house/owner?building=${building}&room=${room}`)
